/*
 * AguardarForm.java
 *
 * Created on 13 de julio de 2008, 04:21
 */

package View;
import Controller.BaseDeDatosController;
import Servicio.Proxy;
import javax.swing.JFileChooser;


/**
 *
 * @author  Gigin
 */
public class AguardarForm extends javax.swing.JDialog {
    private PpalForm ppal;
    private Porcentaje porcentaje=new Porcentaje(0);
    int opcion;
    AguardarForm este;
   
    
    /** Creates new form AguardarForm */
    public AguardarForm(java.awt.Frame parent, boolean modal, PpalForm Ppal) {
        super(parent, modal);
        this.ppal=Ppal;
        este=this;
        initComponents();
      
        
        this.jProgressBar1.setStringPainted(true);
      porcentaje.setValor(0);
    
        Thread barraProgreso=new ThreadBarra("hola");
    Thread importar=new ThreadImportar("gola");
    barraProgreso.start();
    importar.start();
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jProgressBar1 = new javax.swing.JProgressBar();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Monotype Corsiva", 1, 14)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(94, 148, 189));
        jLabel1.setText("CARGANDO EL SISTEMA");

        jProgressBar1.setEnabled(false);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/logo_GTV4.gif"))); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(140, 140, 140)
                        .addComponent(jLabel2))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(99, 99, 99)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))))
                .addContainerGap(95, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addComponent(jLabel1)
                .addGap(7, 7, 7)
                .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(58, 58, 58))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents




class ThreadBarra extends Thread {
    public ThreadBarra (String str) {
        super(str);
    }
    public void run() {

        while (porcentaje.getValor()<100){
        jProgressBar1.setValue(porcentaje.getValor());
        jProgressBar1.repaint();
        Thread.yield();
        }
        jProgressBar1.setValue(porcentaje.getValor());
        jProgressBar1.repaint();
        Thread.yield();
        
    }
    
}

class ThreadImportar extends Thread {
    public ThreadImportar(String str) {
        super(str);
    }
    public void run() {
   
     int falta=Proxy.inicializarProxy();          
     porcentaje.setValor(100-falta);  
     Thread.yield();
     while (falta>0){
         falta=Proxy.inicializarProxy();          
        porcentaje.setValor(100-falta);
     }
     ppal.pantallaModo(ppal,"");
     este.dispose();
    }
    
}

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JProgressBar jProgressBar1;
    // End of variables declaration//GEN-END:variables

}
